/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pl.org.waff.repository;

import com.google.appengine.api.datastore.Entity;
import java.util.Comparator;
import java.util.Date;

/**
 *
 * @author greg
 */
public class PublishedComparator implements Comparator {

    //public int compare(Object o1, Object o2) {
    //int result = -1*((RepositoryObject) o1).getPublished().compareTo(((RepositoryObject) o2).getPublished());
    //return result;
    //}
    public int compare(Object o1, Object o2) {
        Date d1;
        Date d2;
        int result = 0;
        try {
            d1 = (Date) ((Entity) o1).getProperty("published");
            d2 = (Date) ((Entity) o2).getProperty("published");
            result = -1*d1.compareTo(d2);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return result;
    }
}
